#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <stack>
#include <sstream>

using namespace std;

int Func(vector<int>& nums)
{
    nums.push_back(0);
    nums.insert(nums.begin(), 0);
    stack<int> st;
    st.push(0);

    int ret = 0;

    for (int i = 1; i < nums.size(); )
    {
        if (nums[i] >= nums[st.top()]) st.push(i++);
        else
        {
            while (nums[i] < nums[st.top()])
            {
                int top = st.top();
                st.pop();
                ret = max(ret, (i - st.top() - 1) * nums[top]);
            }
        }
    }
    return ret;
}

int main()
{
    vector<int> nums;
    string line;
    getline(cin, line);

    stringstream ss(line);
    int val;
    while (ss >> val)
    {
        nums.push_back(val);
    }

    cout << Func(nums) << endl;

    return 0;
}


class Solution {
public:
    int findDuplicate(vector<int>& nums)
    {
        int left = 1, right = nums.size() - 1;
        int mid;
        while (left < right)
        {
            mid = left + (right - left) / 2;
            int count = 0;
            for (auto e : nums)
            {
                if (e <= mid) count++;
            }
            if (count <= mid) left = mid + 1;
            else right = mid;
        }
        return left;
    }
};

class Solution {
public:
    void nextPermutation(vector<int>& nums)
    {
        int n = nums.size();
        int i = n - 1;
        while (i > 0 && nums[i - 1] >= nums[i]) i--;

        if (i == 0) sort(nums.begin(), nums.end());
        else
        {
            for (int j = n - 1; j >= i; j--)
            {
                if (nums[j] > nums[i - 1])
                {
                    swap(nums[j], nums[i - 1]);
                    sort(nums.begin() + i, nums.end());
                    break;
                }
            }
        }
    }
};

class Solution {

public:
    void sortColors(vector<int>& nums)
    {
        int n = nums.size();
        int begin = -1, end = n;
        int cur = 0;
        while (cur < end)
        {
            if (nums[cur] == 0) swap(nums[cur++], nums[++begin]);
            else if (nums[cur] == 1) cur++;
            else swap(nums[cur], nums[--end]);
        }
    }
};

class Solution {
public:
    int majorityElement(vector<int>& nums)
    {
        int votes = nums[0];
        int count = 1;
        for (int i = 1; i < nums.size(); i++)
        {
            if (count == 0) votes = nums[i];

            if (nums[i] == votes) count++;
            else count--;

        }
        return votes;
    }
};

class Solution {
public:
    int singleNumber(vector<int>& nums)
    {
        int tmp = 0;
        for (auto e : nums) tmp ^= e;
        return tmp;
    }
};